$import( "SmitearWebGL.Objects.Parser.Collada.DaeEntity" );
$import( "SmitearWebGL.Objects.Parser.Collada.DaeInput" );

SmitearWebGL.Objects.Parser.Collada.DaeSampler = SmitearWebGL.Objects.Parser.Collada.DaeEntity.extend(
{
	/******** constructor ********/

	init : function( document, node )
	{
		this.type = "";
		this.values = null;
		this.input = null;
		this.output = null;
		this.interpolation = null;
		this.in_tangent = null;
		this.out_tangent = null;

		this._super( document, node );
		this._registClass( "SmitearWebGL.Objects.Parser.Collada.DaeSampler" );
	}
	,
	read : function( node )
	{
		$THROW( node.localName == SmitearWebGL.Objects.Parser.Collada.Const.DAE_SAMPLER_ELEMENT,
		"expected a '" + SmitearWebGL.Objects.Parser.Collada.Const.DAE_SAMPLER_ELEMENT + "' element" );

		this._super( node );

		var list = node.getElementsByTagName( SmitearWebGL.Objects.Parser.Collada.Const.DAE_INPUT_ELEMENT );
		var child;
		var input;
		var num = list.length;
		var i;

		for(i = 0; i < num; i++)
		{
			child = list[i];

			input = new SmitearWebGL.Objects.Parser.Collada.DaeInput( this.document, child );

			switch( input.semantic )
			{
				case "INPUT":
					this.input = this.document.sources[input.source];
					break;
				case "OUTPUT":
					this.output = this.document.sources[input.source];
					break;
				case "INTERPOLATION":
					this.interpolation = this.document.sources[input.source];
					break;
				case "IN_TANGENT":
					this.in_tangent = this.document.sources[input.source];
					break;
				case "OUT_TANGENT":
					this.out_tangent = this.document.sources[input.source];
					break;
				default:
					$WARNING("[DaeSampler] unhandled semantic: " + input.semantic);
					break;
			}
		}
	}
	,
	destroy : function()
	{
		this._super();

		this.input = null;
		this.output = null;
		this.interpolation = null;
		this.in_tangent = null;
		this.out_tangent = null;
	}
}
);